<template>
  <div class="common-layout">
    <el-container style="height: 100%" class="lay-container">
      <SideBar class="SideBar1" />
      <el-container class="right-container">
        <el-header class="el_header">
          <el-button size="small" @click="handleCollapse" class="header_button">
            <el-icon style="font-size: 16px"><Grid /></el-icon>
          </el-button>
          <!-- 面包屑 -->
          <el-breadcrumb separator="/">
            <el-breadcrumb-item>当前位置</el-breadcrumb-item>
            <el-breadcrumb-item v-for="item in list" :key="item" :to="{ path: item.path }">{{ item.meta.title }}</el-breadcrumb-item>
          </el-breadcrumb>
        </el-header>
        <el-main class="right-main"> <RouterView /></el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script setup>
import SideBar from './components/SideBar.vue'
import { useStore } from 'vuex'
import { computed, onMounted, ref } from 'vue'
import { useRoute } from 'vue-router'
const route = useRoute()

const store = useStore()
//按钮点击事件
const handleCollapse = () => {
  store.commit('changeCollapse')
}

const current = computed(() => {
  // console.log(store.state.currentMenu)
  return store.state.currentMenu
})

//获取菜单值
const cur = computed(() => {
  return store.state.Menu
})

const show = ref(true)
const dd = () => {
  store.state.showClick = false
  store.state.ziCaiDanShow = false
}

/*
面包屑, 需要去路由表中每一项加元信息meta: title: xxxx

*/

onMounted(() => {
  console.log(route)
})
const list = computed(() => {
  console.log(route.matched)
  return route.matched
})
</script>

<style lang="less">
.common-layout {
  height: 100%;
}
.lay-container {
  height: 100%;
  width: 100%;
  display: flex;

  // .SideBar1 {
  //   width: 200px;
  // }
  .right-container {
    flex: 1;
    .el-header {
      // background-color: #ffd00063;

      background-color: #c2f35f9c;

      // background-image: linear-gradient(-20deg, #616161 0%, #9bc5c3 100%);
      width: 100%;
      height: 56px;
    }
  }
}

// icon图标
.el-sub-menu {
  // background-color: #ffae00;
  .el-sub-menu__title {
    img {
      margin-right: 12px;
      width: 32px;
      height: 32px;
    }
    span {
      color: #000;
    }
  }
}

.el_header {
  display: flex;
  align-items: center;
  .el-button {
    margin-right: 20px;
  }
}
.el-breadcrumb__separator {
  color: #333 !important;
}
.el-breadcrumb__inner.is-link,
.el-breadcrumb__inner {
  font-weight: 400;
  color: #333 !important;
}
</style>
